<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - Lua 5.2.4 - src/lvm.c</title>
  <link rel="stylesheet" type="text/css" href="../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../index.html">top level</a> - <a href="index.html">src</a> - lvm.c</td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">Lua 5.2.4</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">288</td>
            <td class="headerCovTableEntry">334</td>
            <td class="headerCovTableEntryMed">86.2 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2019-06-13 19:44:16</td>
            <td></td>
          </tr>
          <tr>
            <td class="headerItem">Legend:</td>
            <td class="headerValueLeg">            Lines:
            <span class="coverLegendCov">hit</span>
            <span class="coverLegendNoCov">not hit</span>
</td>
            <td></td>
          </tr>
          <tr><td><img src="../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<span class="lineNum">       1 </span>            : /*
<span class="lineNum">       2 </span>            : ** $Id: lvm.c,v 2.155.1.1 2013/04/12 18:48:47 roberto Exp $
<span class="lineNum">       3 </span>            : ** Lua virtual machine
<span class="lineNum">       4 </span>            : ** See Copyright Notice in lua.h
<span class="lineNum">       5 </span>            : */
<span class="lineNum">       6 </span>            : 
<span class="lineNum">       7 </span>            : 
<span class="lineNum">       8 </span>            : #include &lt;stdio.h&gt;
<span class="lineNum">       9 </span>            : #include &lt;stdlib.h&gt;
<span class="lineNum">      10 </span>            : #include &lt;string.h&gt;
<span class="lineNum">      11 </span>            : 
<span class="lineNum">      12 </span>            : #define lvm_c
<span class="lineNum">      13 </span>            : #define LUA_CORE
<span class="lineNum">      14 </span>            : 
<span class="lineNum">      15 </span>            : #include &quot;lua.h&quot;
<span class="lineNum">      16 </span>            : 
<span class="lineNum">      17 </span>            : #include &quot;ldebug.h&quot;
<span class="lineNum">      18 </span>            : #include &quot;ldo.h&quot;
<span class="lineNum">      19 </span>            : #include &quot;lfunc.h&quot;
<span class="lineNum">      20 </span>            : #include &quot;lgc.h&quot;
<span class="lineNum">      21 </span>            : #include &quot;lobject.h&quot;
<span class="lineNum">      22 </span>            : #include &quot;lopcodes.h&quot;
<span class="lineNum">      23 </span>            : #include &quot;lstate.h&quot;
<span class="lineNum">      24 </span>            : #include &quot;lstring.h&quot;
<span class="lineNum">      25 </span>            : #include &quot;ltable.h&quot;
<span class="lineNum">      26 </span>            : #include &quot;ltm.h&quot;
<span class="lineNum">      27 </span>            : #include &quot;lvm.h&quot;
<span class="lineNum">      28 </span>            : 
<span class="lineNum">      29 </span>            : 
<span class="lineNum">      30 </span>            : 
<span class="lineNum">      31 </span>            : /* limit for table tag-method chains (to avoid loops) */
<span class="lineNum">      32 </span>            : #define MAXTAGLOOP      100
<span class="lineNum">      33 </span>            : 
<span class="lineNum">      34 </span>            : 
<span class="lineNum">      35 </span><span class="lineCov">        300 : const TValue *luaV_tonumber (const TValue *obj, TValue *n) {</span>
<span class="lineNum">      36 </span>            :   lua_Number num;
<span class="lineNum">      37 </span><span class="lineCov">        300 :   if (ttisnumber(obj)) return obj;</span>
<span class="lineNum">      38 </span><span class="lineCov">        253 :   if (ttisstring(obj) &amp;&amp; luaO_str2d(svalue(obj), tsvalue(obj)-&gt;len, &amp;num)) {</span>
<span class="lineNum">      39 </span><span class="lineCov">         75 :     setnvalue(n, num);</span>
<span class="lineNum">      40 </span><span class="lineCov">         75 :     return n;</span>
<span class="lineNum">      41 </span>            :   }
<span class="lineNum">      42 </span>            :   else
<span class="lineNum">      43 </span><span class="lineCov">        178 :     return NULL;</span>
<span class="lineNum">      44 </span>            : }
<span class="lineNum">      45 </span>            : 
<span class="lineNum">      46 </span>            : 
<span class="lineNum">      47 </span><span class="lineCov">       2244 : int luaV_tostring (lua_State *L, StkId obj) {</span>
<span class="lineNum">      48 </span><span class="lineCov">       2244 :   if (!ttisnumber(obj))</span>
<span class="lineNum">      49 </span><span class="lineCov">         19 :     return 0;</span>
<span class="lineNum">      50 </span>            :   else {
<span class="lineNum">      51 </span>            :     char s[LUAI_MAXNUMBER2STR];
<span class="lineNum">      52 </span><span class="lineCov">       2225 :     lua_Number n = nvalue(obj);</span>
<span class="lineNum">      53 </span><span class="lineCov">       2225 :     int l = lua_number2str(s, n);</span>
<span class="lineNum">      54 </span><span class="lineCov">       2225 :     setsvalue2s(L, obj, luaS_newlstr(L, s, l));</span>
<span class="lineNum">      55 </span><span class="lineCov">       2225 :     return 1;</span>
<span class="lineNum">      56 </span>            :   }
<span class="lineNum">      57 </span>            : }
<span class="lineNum">      58 </span>            : 
<span class="lineNum">      59 </span>            : 
<span class="lineNum">      60 </span><span class="lineCov">         30 : static void traceexec (lua_State *L) {</span>
<span class="lineNum">      61 </span><span class="lineCov">         30 :   CallInfo *ci = L-&gt;ci;</span>
<span class="lineNum">      62 </span><span class="lineCov">         30 :   lu_byte mask = L-&gt;hookmask;</span>
<span class="lineNum">      63 </span><span class="lineCov">         30 :   int counthook = ((mask &amp; LUA_MASKCOUNT) &amp;&amp; L-&gt;hookcount == 0);</span>
<span class="lineNum">      64 </span><span class="lineCov">         30 :   if (counthook)</span>
<span class="lineNum">      65 </span><span class="lineCov">         30 :     resethookcount(L);  /* reset count */</span>
<span class="lineNum">      66 </span><span class="lineCov">         30 :   if (ci-&gt;callstatus &amp; CIST_HOOKYIELD) {  /* called hook last time? */</span>
<span class="lineNum">      67 </span><span class="lineNoCov">          0 :     ci-&gt;callstatus &amp;= ~CIST_HOOKYIELD;  /* erase mark */</span>
<span class="lineNum">      68 </span><span class="lineNoCov">          0 :     return;  /* do not call hook again (VM yielded, so it did not move) */</span>
<span class="lineNum">      69 </span>            :   }
<span class="lineNum">      70 </span><span class="lineCov">         30 :   if (counthook)</span>
<span class="lineNum">      71 </span><span class="lineCov">         30 :     luaD_hook(L, LUA_HOOKCOUNT, -1);  /* call count hook */</span>
<span class="lineNum">      72 </span><span class="lineCov">         30 :   if (mask &amp; LUA_MASKLINE) {</span>
<span class="lineNum">      73 </span><span class="lineNoCov">          0 :     Proto *p = ci_func(ci)-&gt;p;</span>
<span class="lineNum">      74 </span><span class="lineNoCov">          0 :     int npc = pcRel(ci-&gt;u.l.savedpc, p);</span>
<span class="lineNum">      75 </span><span class="lineNoCov">          0 :     int newline = getfuncline(p, npc);</span>
<span class="lineNum">      76 </span><span class="lineNoCov">          0 :     if (npc == 0 ||  /* call linehook when enter a new function, */</span>
<span class="lineNum">      77 </span><span class="lineNoCov">          0 :         ci-&gt;u.l.savedpc &lt;= L-&gt;oldpc ||  /* when jump back (loop), or when */</span>
<span class="lineNum">      78 </span><span class="lineNoCov">          0 :         newline != getfuncline(p, pcRel(L-&gt;oldpc, p)))  /* enter a new line */</span>
<span class="lineNum">      79 </span><span class="lineNoCov">          0 :       luaD_hook(L, LUA_HOOKLINE, newline);  /* call line hook */</span>
<span class="lineNum">      80 </span>            :   }
<span class="lineNum">      81 </span><span class="lineCov">         30 :   L-&gt;oldpc = ci-&gt;u.l.savedpc;</span>
<span class="lineNum">      82 </span><span class="lineCov">         30 :   if (L-&gt;status == LUA_YIELD) {  /* did hook yield? */</span>
<span class="lineNum">      83 </span><span class="lineNoCov">          0 :     if (counthook)</span>
<span class="lineNum">      84 </span><span class="lineNoCov">          0 :       L-&gt;hookcount = 1;  /* undo decrement to zero */</span>
<span class="lineNum">      85 </span><span class="lineNoCov">          0 :     ci-&gt;u.l.savedpc--;  /* undo increment (resume will increment it again) */</span>
<span class="lineNum">      86 </span><span class="lineNoCov">          0 :     ci-&gt;callstatus |= CIST_HOOKYIELD;  /* mark that it yielded */</span>
<span class="lineNum">      87 </span><span class="lineNoCov">          0 :     ci-&gt;func = L-&gt;top - 1;  /* protect stack below results */</span>
<span class="lineNum">      88 </span><span class="lineNoCov">          0 :     luaD_throw(L, LUA_YIELD);</span>
<span class="lineNum">      89 </span>            :   }
<span class="lineNum">      90 </span>            : }
<span class="lineNum">      91 </span>            : 
<span class="lineNum">      92 </span>            : 
<span class="lineNum">      93 </span><span class="lineCov">         56 : static void callTM (lua_State *L, const TValue *f, const TValue *p1,</span>
<span class="lineNum">      94 </span>            :                     const TValue *p2, TValue *p3, int hasres) {
<span class="lineNum">      95 </span><span class="lineCov">         56 :   ptrdiff_t result = savestack(L, p3);</span>
<span class="lineNum">      96 </span><span class="lineCov">         56 :   setobj2s(L, L-&gt;top++, f);  /* push function */</span>
<span class="lineNum">      97 </span><span class="lineCov">         56 :   setobj2s(L, L-&gt;top++, p1);  /* 1st argument */</span>
<span class="lineNum">      98 </span><span class="lineCov">         56 :   setobj2s(L, L-&gt;top++, p2);  /* 2nd argument */</span>
<span class="lineNum">      99 </span><span class="lineCov">         56 :   if (!hasres)  /* no result? 'p3' is third argument */</span>
<span class="lineNum">     100 </span><span class="lineCov">          4 :     setobj2s(L, L-&gt;top++, p3);  /* 3rd argument */</span>
<span class="lineNum">     101 </span>            :   /* metamethod may yield only when called from Lua code */
<span class="lineNum">     102 </span><span class="lineCov">         56 :   luaD_call(L, L-&gt;top - (4 - hasres), hasres, isLua(L-&gt;ci));</span>
<span class="lineNum">     103 </span><span class="lineCov">         51 :   if (hasres) {  /* if has result, move it to its place */</span>
<span class="lineNum">     104 </span><span class="lineCov">         49 :     p3 = restorestack(L, result);</span>
<span class="lineNum">     105 </span><span class="lineCov">         49 :     setobjs2s(L, p3, --L-&gt;top);</span>
<span class="lineNum">     106 </span>            :   }
<span class="lineNum">     107 </span><span class="lineCov">         51 : }</span>
<span class="lineNum">     108 </span>            : 
<span class="lineNum">     109 </span>            : 
<span class="lineNum">     110 </span><span class="lineCov">     134546 : void luaV_gettable (lua_State *L, const TValue *t, TValue *key, StkId val) {</span>
<span class="lineNum">     111 </span>            :   int loop;
<span class="lineNum">     112 </span><span class="lineCov">     141750 :   for (loop = 0; loop &lt; MAXTAGLOOP; loop++) {</span>
<span class="lineNum">     113 </span>            :     const TValue *tm;
<span class="lineNum">     114 </span><span class="lineCov">     141750 :     if (ttistable(t)) {  /* `t' is a table? */</span>
<span class="lineNum">     115 </span><span class="lineCov">     134570 :       Table *h = hvalue(t);</span>
<span class="lineNum">     116 </span><span class="lineCov">     134570 :       const TValue *res = luaH_get(h, key); /* do a primitive get */</span>
<span class="lineNum">     117 </span><span class="lineCov">     134570 :       if (!ttisnil(res) ||  /* result is not nil? */</span>
<span class="lineNum">     118 </span><span class="lineCov">       1127 :           (tm = fasttm(L, h-&gt;metatable, TM_INDEX)) == NULL) { /* or no TM? */</span>
<span class="lineNum">     119 </span><span class="lineCov">     134528 :         setobj2s(L, val, res);</span>
<span class="lineNum">     120 </span><span class="lineCov">     134528 :         return;</span>
<span class="lineNum">     121 </span>            :       }
<span class="lineNum">     122 </span>            :       /* else will try the tag method */
<span class="lineNum">     123 </span>            :     }
<span class="lineNum">     124 </span><span class="lineCov">       7180 :     else if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_INDEX)))</span>
<span class="lineNum">     125 </span><span class="lineCov">          6 :       luaG_typeerror(L, t, &quot;index&quot;);</span>
<span class="lineNum">     126 </span><span class="lineCov">       7216 :     if (ttisfunction(tm)) {</span>
<span class="lineNum">     127 </span><span class="lineCov">         12 :       callTM(L, tm, t, key, val, 1);</span>
<span class="lineNum">     128 </span><span class="lineCov">         12 :       return;</span>
<span class="lineNum">     129 </span>            :     }
<span class="lineNum">     130 </span><span class="lineCov">       7204 :     t = tm;  /* else repeat with 'tm' */</span>
<span class="lineNum">     131 </span>            :   }
<span class="lineNum">     132 </span><span class="lineNoCov">          0 :   luaG_runerror(L, &quot;loop in gettable&quot;);</span>
<span class="lineNum">     133 </span>            : }
<span class="lineNum">     134 </span>            : 
<span class="lineNum">     135 </span>            : 
<span class="lineNum">     136 </span><span class="lineCov">     100060 : void luaV_settable (lua_State *L, const TValue *t, TValue *key, StkId val) {</span>
<span class="lineNum">     137 </span>            :   int loop;
<span class="lineNum">     138 </span><span class="lineCov">     100061 :   for (loop = 0; loop &lt; MAXTAGLOOP; loop++) {</span>
<span class="lineNum">     139 </span>            :     const TValue *tm;
<span class="lineNum">     140 </span><span class="lineCov">     100061 :     if (ttistable(t)) {  /* `t' is a table? */</span>
<span class="lineNum">     141 </span><span class="lineCov">     100053 :       Table *h = hvalue(t);</span>
<span class="lineNum">     142 </span><span class="lineCov">     100053 :       TValue *oldval = cast(TValue *, luaH_get(h, key));</span>
<span class="lineNum">     143 </span>            :       /* if previous value is not nil, there must be a previous entry
<span class="lineNum">     144 </span>            :          in the table; moreover, a metamethod has no relevance */
<span class="lineNum">     145 </span><span class="lineCov">     100053 :       if (!ttisnil(oldval) ||</span>
<span class="lineNum">     146 </span>            :          /* previous value is nil; must check the metamethod */
<span class="lineNum">     147 </span><span class="lineCov">      59134 :          ((tm = fasttm(L, h-&gt;metatable, TM_NEWINDEX)) == NULL &amp;&amp;</span>
<span class="lineNum">     148 </span>            :          /* no metamethod; is there a previous entry in the table? */
<span class="lineNum">     149 </span>            :          (oldval != luaO_nilobject ||
<span class="lineNum">     150 </span>            :          /* no previous entry; must create one. (The next test is
<span class="lineNum">     151 </span>            :             always true; we only need the assignment.) */
<span class="lineNum">     152 </span><span class="lineCov">      41401 :          (oldval = luaH_newkey(L, h, key), 1)))) {</span>
<span class="lineNum">     153 </span>            :         /* no metamethod and (now) there is an entry with given key */
<span class="lineNum">     154 </span><span class="lineCov">     100046 :         setobj2t(L, oldval, val);  /* assign new value to that entry */</span>
<span class="lineNum">     155 </span><span class="lineCov">     100046 :         invalidateTMcache(h);</span>
<span class="lineNum">     156 </span><span class="lineCov">     100046 :         luaC_barrierback(L, obj2gco(h), val);</span>
<span class="lineNum">     157 </span><span class="lineCov">     100046 :         return;</span>
<span class="lineNum">     158 </span>            :       }
<span class="lineNum">     159 </span>            :       /* else will try the metamethod */
<span class="lineNum">     160 </span>            :     }
<span class="lineNum">     161 </span>            :     else  /* not a table; check metamethod */
<span class="lineNum">     162 </span><span class="lineCov">          8 :       if (ttisnil(tm = luaT_gettmbyobj(L, t, TM_NEWINDEX)))</span>
<span class="lineNum">     163 </span><span class="lineCov">          8 :         luaG_typeerror(L, t, &quot;index&quot;);</span>
<span class="lineNum">     164 </span>            :     /* there is a metamethod */
<span class="lineNum">     165 </span><span class="lineCov">          5 :     if (ttisfunction(tm)) {</span>
<span class="lineNum">     166 </span><span class="lineCov">          4 :       callTM(L, tm, t, key, val, 0);</span>
<span class="lineNum">     167 </span><span class="lineCov">          2 :       return;</span>
<span class="lineNum">     168 </span>            :     }
<span class="lineNum">     169 </span><span class="lineCov">          1 :     t = tm;  /* else repeat with 'tm' */</span>
<span class="lineNum">     170 </span>            :   }
<span class="lineNum">     171 </span><span class="lineNoCov">          0 :   luaG_runerror(L, &quot;loop in settable&quot;);</span>
<span class="lineNum">     172 </span>            : }
<span class="lineNum">     173 </span>            : 
<span class="lineNum">     174 </span>            : 
<span class="lineNum">     175 </span><span class="lineCov">        225 : static int call_binTM (lua_State *L, const TValue *p1, const TValue *p2,</span>
<span class="lineNum">     176 </span>            :                        StkId res, TMS event) {
<span class="lineNum">     177 </span><span class="lineCov">        225 :   const TValue *tm = luaT_gettmbyobj(L, p1, event);  /* try first operand */</span>
<span class="lineNum">     178 </span><span class="lineCov">        225 :   if (ttisnil(tm))</span>
<span class="lineNum">     179 </span><span class="lineCov">        201 :     tm = luaT_gettmbyobj(L, p2, event);  /* try second operand */</span>
<span class="lineNum">     180 </span><span class="lineCov">        225 :   if (ttisnil(tm)) return 0;</span>
<span class="lineNum">     181 </span><span class="lineCov">         32 :   callTM(L, tm, p1, p2, res, 1);</span>
<span class="lineNum">     182 </span><span class="lineCov">         32 :   return 1;</span>
<span class="lineNum">     183 </span>            : }
<span class="lineNum">     184 </span>            : 
<span class="lineNum">     185 </span>            : 
<span class="lineNum">     186 </span><span class="lineCov">         10 : static const TValue *get_equalTM (lua_State *L, Table *mt1, Table *mt2,</span>
<span class="lineNum">     187 </span>            :                                   TMS event) {
<span class="lineNum">     188 </span><span class="lineCov">         10 :   const TValue *tm1 = fasttm(L, mt1, event);</span>
<span class="lineNum">     189 </span>            :   const TValue *tm2;
<span class="lineNum">     190 </span><span class="lineCov">         10 :   if (tm1 == NULL) return NULL;  /* no metamethod */</span>
<span class="lineNum">     191 </span><span class="lineCov">          5 :   if (mt1 == mt2) return tm1;  /* same metatables =&gt; same metamethods */</span>
<span class="lineNum">     192 </span><span class="lineNoCov">          0 :   tm2 = fasttm(L, mt2, event);</span>
<span class="lineNum">     193 </span><span class="lineNoCov">          0 :   if (tm2 == NULL) return NULL;  /* no metamethod */</span>
<span class="lineNum">     194 </span><span class="lineNoCov">          0 :   if (luaV_rawequalobj(tm1, tm2))  /* same metamethods? */</span>
<span class="lineNum">     195 </span><span class="lineNoCov">          0 :     return tm1;</span>
<span class="lineNum">     196 </span><span class="lineNoCov">          0 :   return NULL;</span>
<span class="lineNum">     197 </span>            : }
<span class="lineNum">     198 </span>            : 
<span class="lineNum">     199 </span>            : 
<span class="lineNum">     200 </span><span class="lineCov">        114 : static int call_orderTM (lua_State *L, const TValue *p1, const TValue *p2,</span>
<span class="lineNum">     201 </span>            :                          TMS event) {
<span class="lineNum">     202 </span><span class="lineCov">        114 :   if (!call_binTM(L, p1, p2, L-&gt;top, event))</span>
<span class="lineNum">     203 </span><span class="lineCov">        106 :     return -1;  /* no metamethod */</span>
<span class="lineNum">     204 </span>            :   else
<span class="lineNum">     205 </span><span class="lineCov">          8 :     return !l_isfalse(L-&gt;top);</span>
<span class="lineNum">     206 </span>            : }
<span class="lineNum">     207 </span>            : 
<span class="lineNum">     208 </span>            : 
<span class="lineNum">     209 </span><span class="lineCov">      91700 : static int l_strcmp (const TString *ls, const TString *rs) {</span>
<span class="lineNum">     210 </span><span class="lineCov">      91700 :   const char *l = getstr(ls);</span>
<span class="lineNum">     211 </span><span class="lineCov">      91700 :   size_t ll = ls-&gt;tsv.len;</span>
<span class="lineNum">     212 </span><span class="lineCov">      91700 :   const char *r = getstr(rs);</span>
<span class="lineNum">     213 </span><span class="lineCov">      91700 :   size_t lr = rs-&gt;tsv.len;</span>
<span class="lineNum">     214 </span><span class="lineCov">          1 :   for (;;) {</span>
<span class="lineNum">     215 </span><span class="lineCov">      91701 :     int temp = strcoll(l, r);</span>
<span class="lineNum">     216 </span><span class="lineCov">      91701 :     if (temp != 0) return temp;</span>
<span class="lineNum">     217 </span>            :     else {  /* strings are equal up to a `\0' */
<span class="lineNum">     218 </span><span class="lineCov">       2672 :       size_t len = strlen(l);  /* index of first `\0' in both strings */</span>
<span class="lineNum">     219 </span><span class="lineCov">       2672 :       if (len == lr)  /* r is finished? */</span>
<span class="lineNum">     220 </span><span class="lineCov">       2670 :         return (len == ll) ? 0 : 1;</span>
<span class="lineNum">     221 </span><span class="lineCov">          2 :       else if (len == ll)  /* l is finished? */</span>
<span class="lineNum">     222 </span><span class="lineCov">          1 :         return -1;  /* l is smaller than r (because r is not finished) */</span>
<span class="lineNum">     223 </span>            :       /* both strings longer than `len'; go on comparing (after the `\0') */
<span class="lineNum">     224 </span><span class="lineCov">          1 :       len++;</span>
<span class="lineNum">     225 </span><span class="lineCov">          1 :       l += len; ll -= len; r += len; lr -= len;</span>
<span class="lineNum">     226 </span>            :     }
<span class="lineNum">     227 </span>            :   }
<span class="lineNum">     228 </span>            : }
<span class="lineNum">     229 </span>            : 
<span class="lineNum">     230 </span>            : 
<span class="lineNum">     231 </span><span class="lineCov">      91725 : int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {</span>
<span class="lineNum">     232 </span>            :   int res;
<span class="lineNum">     233 </span><span class="lineCov">      91725 :   if (ttisnumber(l) &amp;&amp; ttisnumber(r))</span>
<span class="lineNum">     234 </span><span class="lineCov">         54 :     return luai_numlt(L, nvalue(l), nvalue(r));</span>
<span class="lineNum">     235 </span><span class="lineCov">      91671 :   else if (ttisstring(l) &amp;&amp; ttisstring(r))</span>
<span class="lineNum">     236 </span><span class="lineCov">      91622 :     return l_strcmp(rawtsvalue(l), rawtsvalue(r)) &lt; 0;</span>
<span class="lineNum">     237 </span><span class="lineCov">         49 :   else if ((res = call_orderTM(L, l, r, TM_LT)) &lt; 0)</span>
<span class="lineNum">     238 </span><span class="lineCov">         43 :     luaG_ordererror(L, l, r);</span>
<span class="lineNum">     239 </span><span class="lineCov">          6 :   return res;</span>
<span class="lineNum">     240 </span>            : }
<span class="lineNum">     241 </span>            : 
<span class="lineNum">     242 </span>            : 
<span class="lineNum">     243 </span><span class="lineCov">      11039 : int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) {</span>
<span class="lineNum">     244 </span>            :   int res;
<span class="lineNum">     245 </span><span class="lineCov">      11039 :   if (ttisnumber(l) &amp;&amp; ttisnumber(r))</span>
<span class="lineNum">     246 </span><span class="lineCov">      10928 :     return luai_numle(L, nvalue(l), nvalue(r));</span>
<span class="lineNum">     247 </span><span class="lineCov">        111 :   else if (ttisstring(l) &amp;&amp; ttisstring(r))</span>
<span class="lineNum">     248 </span><span class="lineCov">         78 :     return l_strcmp(rawtsvalue(l), rawtsvalue(r)) &lt;= 0;</span>
<span class="lineNum">     249 </span><span class="lineCov">         33 :   else if ((res = call_orderTM(L, l, r, TM_LE)) &gt;= 0)  /* first try `le' */</span>
<span class="lineNum">     250 </span><span class="lineCov">          1 :     return res;</span>
<span class="lineNum">     251 </span><span class="lineCov">         32 :   else if ((res = call_orderTM(L, r, l, TM_LT)) &lt; 0)  /* else try `lt' */</span>
<span class="lineNum">     252 </span><span class="lineCov">         31 :     luaG_ordererror(L, l, r);</span>
<span class="lineNum">     253 </span><span class="lineCov">          1 :   return !res;</span>
<span class="lineNum">     254 </span>            : }
<span class="lineNum">     255 </span>            : 
<span class="lineNum">     256 </span>            : 
<span class="lineNum">     257 </span>            : /*
<span class="lineNum">     258 </span>            : ** equality of Lua values. L == NULL means raw equality (no metamethods)
<span class="lineNum">     259 </span>            : */
<span class="lineNum">     260 </span><span class="lineCov">      39441 : int luaV_equalobj_ (lua_State *L, const TValue *t1, const TValue *t2) {</span>
<span class="lineNum">     261 </span>            :   const TValue *tm;
<span class="lineNum">     262 </span>            :   lua_assert(ttisequal(t1, t2));
<span class="lineNum">     263 </span><span class="lineCov">      39441 :   switch (ttype(t1)) {</span>
<span class="lineNum">     264 </span><span class="lineCov">        157 :     case LUA_TNIL: return 1;</span>
<span class="lineNum">     265 </span><span class="lineCov">       2814 :     case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2));</span>
<span class="lineNum">     266 </span><span class="lineCov">        171 :     case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2);  /* true must be 1 !! */</span>
<span class="lineNum">     267 </span><span class="lineNoCov">          0 :     case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);</span>
<span class="lineNum">     268 </span><span class="lineCov">        945 :     case LUA_TLCF: return fvalue(t1) == fvalue(t2);</span>
<span class="lineNum">     269 </span><span class="lineCov">      33147 :     case LUA_TSHRSTR: return eqshrstr(rawtsvalue(t1), rawtsvalue(t2));</span>
<span class="lineNum">     270 </span><span class="lineCov">        573 :     case LUA_TLNGSTR: return luaS_eqlngstr(rawtsvalue(t1), rawtsvalue(t2));</span>
<span class="lineNum">     271 </span><span class="lineCov">         11 :     case LUA_TUSERDATA: {</span>
<span class="lineNum">     272 </span><span class="lineCov">         11 :       if (uvalue(t1) == uvalue(t2)) return 1;</span>
<span class="lineNum">     273 </span><span class="lineCov">          1 :       else if (L == NULL) return 0;</span>
<span class="lineNum">     274 </span><span class="lineCov">          1 :       tm = get_equalTM(L, uvalue(t1)-&gt;metatable, uvalue(t2)-&gt;metatable, TM_EQ);</span>
<span class="lineNum">     275 </span><span class="lineCov">          1 :       break;  /* will try TM */</span>
<span class="lineNum">     276 </span>            :     }
<span class="lineNum">     277 </span><span class="lineCov">       1390 :     case LUA_TTABLE: {</span>
<span class="lineNum">     278 </span><span class="lineCov">       1390 :       if (hvalue(t1) == hvalue(t2)) return 1;</span>
<span class="lineNum">     279 </span><span class="lineCov">         10 :       else if (L == NULL) return 0;</span>
<span class="lineNum">     280 </span><span class="lineCov">          9 :       tm = get_equalTM(L, hvalue(t1)-&gt;metatable, hvalue(t2)-&gt;metatable, TM_EQ);</span>
<span class="lineNum">     281 </span><span class="lineCov">          9 :       break;  /* will try TM */</span>
<span class="lineNum">     282 </span>            :     }
<span class="lineNum">     283 </span><span class="lineCov">        233 :     default:</span>
<span class="lineNum">     284 </span>            :       lua_assert(iscollectable(t1));
<span class="lineNum">     285 </span><span class="lineCov">        233 :       return gcvalue(t1) == gcvalue(t2);</span>
<span class="lineNum">     286 </span>            :   }
<span class="lineNum">     287 </span><span class="lineCov">         10 :   if (tm == NULL) return 0;  /* no TM? */</span>
<span class="lineNum">     288 </span><span class="lineCov">          5 :   callTM(L, tm, t1, t2, L-&gt;top, 1);  /* call TM */</span>
<span class="lineNum">     289 </span><span class="lineCov">          2 :   return !l_isfalse(L-&gt;top);</span>
<span class="lineNum">     290 </span>            : }
<span class="lineNum">     291 </span>            : 
<span class="lineNum">     292 </span>            : 
<span class="lineNum">     293 </span><span class="lineCov">      10783 : void luaV_concat (lua_State *L, int total) {</span>
<span class="lineNum">     294 </span>            :   lua_assert(total &gt;= 2);
<span class="lineNum">     295 </span>            :   do {
<span class="lineNum">     296 </span><span class="lineCov">      10783 :     StkId top = L-&gt;top;</span>
<span class="lineNum">     297 </span><span class="lineCov">      10783 :     int n = 2;  /* number of elements handled in this pass (at least 2) */</span>
<span class="lineNum">     298 </span><span class="lineCov">      10783 :     if (!(ttisstring(top-2) || ttisnumber(top-2)) || !tostring(L, top-1)) {</span>
<span class="lineNum">     299 </span><span class="lineCov">         12 :       if (!call_binTM(L, top-2, top-1, top-2, TM_CONCAT))</span>
<span class="lineNum">     300 </span><span class="lineCov">          9 :         luaG_concaterror(L, top-2, top-1);</span>
<span class="lineNum">     301 </span>            :     }
<span class="lineNum">     302 </span><span class="lineCov">      10771 :     else if (tsvalue(top-1)-&gt;len == 0)  /* second operand is empty? */</span>
<span class="lineNum">     303 </span><span class="lineCov">        578 :       (void)tostring(L, top - 2);  /* result is first operand */</span>
<span class="lineNum">     304 </span><span class="lineCov">      10193 :     else if (ttisstring(top-2) &amp;&amp; tsvalue(top-2)-&gt;len == 0) {</span>
<span class="lineNum">     305 </span><span class="lineCov">        716 :       setobjs2s(L, top - 2, top - 1);  /* result is second op. */</span>
<span class="lineNum">     306 </span>            :     }
<span class="lineNum">     307 </span>            :     else {
<span class="lineNum">     308 </span>            :       /* at least two non-empty string values; get as many as possible */
<span class="lineNum">     309 </span><span class="lineCov">       9477 :       size_t tl = tsvalue(top-1)-&gt;len;</span>
<span class="lineNum">     310 </span>            :       char *buffer;
<span class="lineNum">     311 </span>            :       int i;
<span class="lineNum">     312 </span>            :       /* collect total length */
<span class="lineNum">     313 </span><span class="lineCov">      25870 :       for (i = 1; i &lt; total &amp;&amp; tostring(L, top-i-1); i++) {</span>
<span class="lineNum">     314 </span><span class="lineCov">      16393 :         size_t l = tsvalue(top-i-1)-&gt;len;</span>
<span class="lineNum">     315 </span><span class="lineCov">      16393 :         if (l &gt;= (MAX_SIZET/sizeof(char)) - tl)</span>
<span class="lineNum">     316 </span><span class="lineNoCov">          0 :           luaG_runerror(L, &quot;string length overflow&quot;);</span>
<span class="lineNum">     317 </span><span class="lineCov">      16393 :         tl += l;</span>
<span class="lineNum">     318 </span>            :       }
<span class="lineNum">     319 </span><span class="lineCov">       9477 :       buffer = luaZ_openspace(L, &amp;G(L)-&gt;buff, tl);</span>
<span class="lineNum">     320 </span><span class="lineCov">       9477 :       tl = 0;</span>
<span class="lineNum">     321 </span><span class="lineCov">       9477 :       n = i;</span>
<span class="lineNum">     322 </span>            :       do {  /* concat all strings */
<span class="lineNum">     323 </span><span class="lineCov">      25870 :         size_t l = tsvalue(top-i)-&gt;len;</span>
<span class="lineNum">     324 </span><span class="lineCov">      25870 :         memcpy(buffer+tl, svalue(top-i), l * sizeof(char));</span>
<span class="lineNum">     325 </span><span class="lineCov">      25870 :         tl += l;</span>
<span class="lineNum">     326 </span><span class="lineCov">      25870 :       } while (--i &gt; 0);</span>
<span class="lineNum">     327 </span><span class="lineCov">       9477 :       setsvalue2s(L, top-n, luaS_newlstr(L, buffer, tl));</span>
<span class="lineNum">     328 </span>            :     }
<span class="lineNum">     329 </span><span class="lineCov">      10774 :     total -= n-1;  /* got 'n' strings to create 1 new */</span>
<span class="lineNum">     330 </span><span class="lineCov">      10774 :     L-&gt;top -= n-1;  /* popped 'n' strings and pushed one */</span>
<span class="lineNum">     331 </span><span class="lineCov">      10774 :   } while (total &gt; 1);  /* repeat until only 1 result left */</span>
<span class="lineNum">     332 </span><span class="lineCov">      10193 : }</span>
<span class="lineNum">     333 </span>            : 
<span class="lineNum">     334 </span>            : 
<span class="lineNum">     335 </span><span class="lineCov">      18679 : void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) {</span>
<span class="lineNum">     336 </span>            :   const TValue *tm;
<span class="lineNum">     337 </span><span class="lineCov">      18679 :   switch (ttypenv(rb)) {</span>
<span class="lineNum">     338 </span><span class="lineCov">      18672 :     case LUA_TTABLE: {</span>
<span class="lineNum">     339 </span><span class="lineCov">      18672 :       Table *h = hvalue(rb);</span>
<span class="lineNum">     340 </span><span class="lineCov">      18672 :       tm = fasttm(L, h-&gt;metatable, TM_LEN);</span>
<span class="lineNum">     341 </span><span class="lineCov">      18672 :       if (tm) break;  /* metamethod? break switch to call it */</span>
<span class="lineNum">     342 </span><span class="lineCov">      18669 :       setnvalue(ra, cast_num(luaH_getn(h)));  /* else primitive len */</span>
<span class="lineNum">     343 </span><span class="lineCov">      18669 :       return;</span>
<span class="lineNum">     344 </span>            :     }
<span class="lineNum">     345 </span><span class="lineCov">          1 :     case LUA_TSTRING: {</span>
<span class="lineNum">     346 </span><span class="lineCov">          1 :       setnvalue(ra, cast_num(tsvalue(rb)-&gt;len));</span>
<span class="lineNum">     347 </span><span class="lineCov">          1 :       return;</span>
<span class="lineNum">     348 </span>            :     }
<span class="lineNum">     349 </span><span class="lineCov">          6 :     default: {  /* try metamethod */</span>
<span class="lineNum">     350 </span><span class="lineCov">          6 :       tm = luaT_gettmbyobj(L, rb, TM_LEN);</span>
<span class="lineNum">     351 </span><span class="lineCov">          6 :       if (ttisnil(tm))  /* no metamethod? */</span>
<span class="lineNum">     352 </span><span class="lineCov">          6 :         luaG_typeerror(L, rb, &quot;get length of&quot;);</span>
<span class="lineNum">     353 </span><span class="lineNoCov">          0 :       break;</span>
<span class="lineNum">     354 </span>            :     }
<span class="lineNum">     355 </span>            :   }
<span class="lineNum">     356 </span><span class="lineCov">          3 :   callTM(L, tm, rb, rb, ra, 1);</span>
<span class="lineNum">     357 </span>            : }
<span class="lineNum">     358 </span>            : 
<span class="lineNum">     359 </span>            : 
<span class="lineNum">     360 </span><span class="lineCov">        123 : void luaV_arith (lua_State *L, StkId ra, const TValue *rb,</span>
<span class="lineNum">     361 </span>            :                  const TValue *rc, TMS op) {
<span class="lineNum">     362 </span>            :   TValue tempb, tempc;
<span class="lineNum">     363 </span>            :   const TValue *b, *c;
<span class="lineNum">     364 </span><span class="lineCov">        182 :   if ((b = luaV_tonumber(rb, &amp;tempb)) != NULL &amp;&amp;</span>
<span class="lineNum">     365 </span><span class="lineCov">         59 :       (c = luaV_tonumber(rc, &amp;tempc)) != NULL) {</span>
<span class="lineNum">     366 </span><span class="lineCov">         24 :     lua_Number res = luaO_arith(op - TM_ADD + LUA_OPADD, nvalue(b), nvalue(c));</span>
<span class="lineNum">     367 </span><span class="lineCov">         24 :     setnvalue(ra, res);</span>
<span class="lineNum">     368 </span>            :   }
<span class="lineNum">     369 </span><span class="lineCov">         99 :   else if (!call_binTM(L, rb, rc, ra, op))</span>
<span class="lineNum">     370 </span><span class="lineCov">         78 :     luaG_aritherror(L, rb, rc);</span>
<span class="lineNum">     371 </span><span class="lineCov">         45 : }</span>
<span class="lineNum">     372 </span>            : 
<span class="lineNum">     373 </span>            : 
<span class="lineNum">     374 </span>            : /*
<span class="lineNum">     375 </span>            : ** check whether cached closure in prototype 'p' may be reused, that is,
<span class="lineNum">     376 </span>            : ** whether there is a cached closure with the same upvalues needed by
<span class="lineNum">     377 </span>            : ** new closure to be created.
<span class="lineNum">     378 </span>            : */
<span class="lineNum">     379 </span><span class="lineCov">       2272 : static Closure *getcached (Proto *p, UpVal **encup, StkId base) {</span>
<span class="lineNum">     380 </span><span class="lineCov">       2272 :   Closure *c = p-&gt;cache;</span>
<span class="lineNum">     381 </span><span class="lineCov">       2272 :   if (c != NULL) {  /* is there a cached closure? */</span>
<span class="lineNum">     382 </span><span class="lineCov">        908 :     int nup = p-&gt;sizeupvalues;</span>
<span class="lineNum">     383 </span><span class="lineCov">        908 :     Upvaldesc *uv = p-&gt;upvalues;</span>
<span class="lineNum">     384 </span>            :     int i;
<span class="lineNum">     385 </span><span class="lineCov">        924 :     for (i = 0; i &lt; nup; i++) {  /* check whether it has right upvalues */</span>
<span class="lineNum">     386 </span><span class="lineCov">        922 :       TValue *v = uv[i].instack ? base + uv[i].idx : encup[uv[i].idx]-&gt;v;</span>
<span class="lineNum">     387 </span><span class="lineCov">        922 :       if (c-&gt;l.upvals[i]-&gt;v != v)</span>
<span class="lineNum">     388 </span><span class="lineCov">        906 :         return NULL;  /* wrong upvalue; cannot reuse closure */</span>
<span class="lineNum">     389 </span>            :     }
<span class="lineNum">     390 </span>            :   }
<span class="lineNum">     391 </span><span class="lineCov">       1366 :   return c;  /* return cached closure (or NULL if no cached closure) */</span>
<span class="lineNum">     392 </span>            : }
<span class="lineNum">     393 </span>            : 
<span class="lineNum">     394 </span>            : 
<span class="lineNum">     395 </span>            : /*
<span class="lineNum">     396 </span>            : ** create a new Lua closure, push it in the stack, and initialize
<span class="lineNum">     397 </span>            : ** its upvalues. Note that the call to 'luaC_barrierproto' must come
<span class="lineNum">     398 </span>            : ** before the assignment to 'p-&gt;cache', as the function needs the
<span class="lineNum">     399 </span>            : ** original value of that field.
<span class="lineNum">     400 </span>            : */
<span class="lineNum">     401 </span><span class="lineCov">       2270 : static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,</span>
<span class="lineNum">     402 </span>            :                          StkId ra) {
<span class="lineNum">     403 </span><span class="lineCov">       2270 :   int nup = p-&gt;sizeupvalues;</span>
<span class="lineNum">     404 </span><span class="lineCov">       2270 :   Upvaldesc *uv = p-&gt;upvalues;</span>
<span class="lineNum">     405 </span>            :   int i;
<span class="lineNum">     406 </span><span class="lineCov">       2270 :   Closure *ncl = luaF_newLclosure(L, nup);</span>
<span class="lineNum">     407 </span><span class="lineCov">       2270 :   ncl-&gt;l.p = p;</span>
<span class="lineNum">     408 </span><span class="lineCov">       2270 :   setclLvalue(L, ra, ncl);  /* anchor new closure in stack */</span>
<span class="lineNum">     409 </span><span class="lineCov">      10139 :   for (i = 0; i &lt; nup; i++) {  /* fill in its upvalues */</span>
<span class="lineNum">     410 </span><span class="lineCov">       7869 :     if (uv[i].instack)  /* upvalue refers to local variable? */</span>
<span class="lineNum">     411 </span><span class="lineCov">       6306 :       ncl-&gt;l.upvals[i] = luaF_findupval(L, base + uv[i].idx);</span>
<span class="lineNum">     412 </span>            :     else  /* get upvalue from enclosing function */
<span class="lineNum">     413 </span><span class="lineCov">       1563 :       ncl-&gt;l.upvals[i] = encup[uv[i].idx];</span>
<span class="lineNum">     414 </span>            :   }
<span class="lineNum">     415 </span><span class="lineCov">       2270 :   luaC_barrierproto(L, p, ncl);</span>
<span class="lineNum">     416 </span><span class="lineCov">       2270 :   p-&gt;cache = ncl;  /* save it on cache for reuse */</span>
<span class="lineNum">     417 </span><span class="lineCov">       2270 : }</span>
<span class="lineNum">     418 </span>            : 
<span class="lineNum">     419 </span>            : 
<span class="lineNum">     420 </span>            : /*
<span class="lineNum">     421 </span>            : ** finish execution of an opcode interrupted by an yield
<span class="lineNum">     422 </span>            : */
<span class="lineNum">     423 </span><span class="lineCov">       5954 : void luaV_finishOp (lua_State *L) {</span>
<span class="lineNum">     424 </span><span class="lineCov">       5954 :   CallInfo *ci = L-&gt;ci;</span>
<span class="lineNum">     425 </span><span class="lineCov">       5954 :   StkId base = ci-&gt;u.l.base;</span>
<span class="lineNum">     426 </span><span class="lineCov">       5954 :   Instruction inst = *(ci-&gt;u.l.savedpc - 1);  /* interrupted instruction */</span>
<span class="lineNum">     427 </span><span class="lineCov">       5954 :   OpCode op = GET_OPCODE(inst);</span>
<span class="lineNum">     428 </span><span class="lineCov">       5954 :   switch (op) {  /* finish its execution */</span>
<span class="lineNum">     429 </span><span class="lineNoCov">          0 :     case OP_ADD: case OP_SUB: case OP_MUL: case OP_DIV:</span>
<span class="lineNum">     430 </span>            :     case OP_MOD: case OP_POW: case OP_UNM: case OP_LEN:
<span class="lineNum">     431 </span>            :     case OP_GETTABUP: case OP_GETTABLE: case OP_SELF: {
<span class="lineNum">     432 </span><span class="lineNoCov">          0 :       setobjs2s(L, base + GETARG_A(inst), --L-&gt;top);</span>
<span class="lineNum">     433 </span><span class="lineNoCov">          0 :       break;</span>
<span class="lineNum">     434 </span>            :     }
<span class="lineNum">     435 </span><span class="lineCov">          2 :     case OP_LE: case OP_LT: case OP_EQ: {</span>
<span class="lineNum">     436 </span><span class="lineCov">          2 :       int res = !l_isfalse(L-&gt;top - 1);</span>
<span class="lineNum">     437 </span><span class="lineCov">          2 :       L-&gt;top--;</span>
<span class="lineNum">     438 </span>            :       /* metamethod should not be called when operand is K */
<span class="lineNum">     439 </span>            :       lua_assert(!ISK(GETARG_B(inst)));
<span class="lineNum">     440 </span><span class="lineCov">          2 :       if (op == OP_LE &amp;&amp;  /* &quot;&lt;=&quot; using &quot;&lt;&quot; instead? */</span>
<span class="lineNum">     441 </span><span class="lineNoCov">          0 :           ttisnil(luaT_gettmbyobj(L, base + GETARG_B(inst), TM_LE)))</span>
<span class="lineNum">     442 </span><span class="lineNoCov">          0 :         res = !res;  /* invert result */</span>
<span class="lineNum">     443 </span>            :       lua_assert(GET_OPCODE(*ci-&gt;u.l.savedpc) == OP_JMP);
<span class="lineNum">     444 </span><span class="lineCov">          2 :       if (res != GETARG_A(inst))  /* condition failed? */</span>
<span class="lineNum">     445 </span><span class="lineCov">          1 :         ci-&gt;u.l.savedpc++;  /* skip jump instruction */</span>
<span class="lineNum">     446 </span><span class="lineCov">          2 :       break;</span>
<span class="lineNum">     447 </span>            :     }
<span class="lineNum">     448 </span><span class="lineNoCov">          0 :     case OP_CONCAT: {</span>
<span class="lineNum">     449 </span><span class="lineNoCov">          0 :       StkId top = L-&gt;top - 1;  /* top when 'call_binTM' was called */</span>
<span class="lineNum">     450 </span><span class="lineNoCov">          0 :       int b = GETARG_B(inst);      /* first element to concatenate */</span>
<span class="lineNum">     451 </span><span class="lineNoCov">          0 :       int total = cast_int(top - 1 - (base + b));  /* yet to concatenate */</span>
<span class="lineNum">     452 </span><span class="lineNoCov">          0 :       setobj2s(L, top - 2, top);  /* put TM result in proper position */</span>
<span class="lineNum">     453 </span><span class="lineNoCov">          0 :       if (total &gt; 1) {  /* are there elements to concat? */</span>
<span class="lineNum">     454 </span><span class="lineNoCov">          0 :         L-&gt;top = top - 1;  /* top is one after last element (at top-2) */</span>
<span class="lineNum">     455 </span><span class="lineNoCov">          0 :         luaV_concat(L, total);  /* concat them (may yield again) */</span>
<span class="lineNum">     456 </span>            :       }
<span class="lineNum">     457 </span>            :       /* move final result to final position */
<span class="lineNum">     458 </span><span class="lineNoCov">          0 :       setobj2s(L, ci-&gt;u.l.base + GETARG_A(inst), L-&gt;top - 1);</span>
<span class="lineNum">     459 </span><span class="lineNoCov">          0 :       L-&gt;top = ci-&gt;top;  /* restore top */</span>
<span class="lineNum">     460 </span><span class="lineNoCov">          0 :       break;</span>
<span class="lineNum">     461 </span>            :     }
<span class="lineNum">     462 </span><span class="lineNoCov">          0 :     case OP_TFORCALL: {</span>
<span class="lineNum">     463 </span>            :       lua_assert(GET_OPCODE(*ci-&gt;u.l.savedpc) == OP_TFORLOOP);
<span class="lineNum">     464 </span><span class="lineNoCov">          0 :       L-&gt;top = ci-&gt;top;  /* correct top */</span>
<span class="lineNum">     465 </span><span class="lineNoCov">          0 :       break;</span>
<span class="lineNum">     466 </span>            :     }
<span class="lineNum">     467 </span><span class="lineCov">       5945 :     case OP_CALL: {</span>
<span class="lineNum">     468 </span><span class="lineCov">       5945 :       if (GETARG_C(inst) - 1 &gt;= 0)  /* nresults &gt;= 0? */</span>
<span class="lineNum">     469 </span><span class="lineCov">       5945 :         L-&gt;top = ci-&gt;top;  /* adjust results */</span>
<span class="lineNum">     470 </span><span class="lineCov">       5945 :       break;</span>
<span class="lineNum">     471 </span>            :     }
<span class="lineNum">     472 </span><span class="lineCov">          7 :     case OP_TAILCALL: case OP_SETTABUP: case OP_SETTABLE:</span>
<span class="lineNum">     473 </span><span class="lineCov">          7 :       break;</span>
<span class="lineNum">     474 </span><span class="lineCov">       5954 :     default: lua_assert(0);</span>
<span class="lineNum">     475 </span>            :   }
<span class="lineNum">     476 </span><span class="lineCov">       5954 : }</span>
<span class="lineNum">     477 </span>            : 
<span class="lineNum">     478 </span>            : 
<span class="lineNum">     479 </span>            : 
<span class="lineNum">     480 </span>            : /*
<span class="lineNum">     481 </span>            : ** some macros for common tasks in `luaV_execute'
<span class="lineNum">     482 </span>            : */
<span class="lineNum">     483 </span>            : 
<span class="lineNum">     484 </span>            : #if !defined luai_runtimecheck
<span class="lineNum">     485 </span>            : #define luai_runtimecheck(L, c)         /* void */
<span class="lineNum">     486 </span>            : #endif
<span class="lineNum">     487 </span>            : 
<span class="lineNum">     488 </span>            : 
<span class="lineNum">     489 </span>            : #define RA(i)   (base+GETARG_A(i))
<span class="lineNum">     490 </span>            : /* to be used after possible stack reallocation */
<span class="lineNum">     491 </span>            : #define RB(i)   check_exp(getBMode(GET_OPCODE(i)) == OpArgR, base+GETARG_B(i))
<span class="lineNum">     492 </span>            : #define RC(i)   check_exp(getCMode(GET_OPCODE(i)) == OpArgR, base+GETARG_C(i))
<span class="lineNum">     493 </span>            : #define RKB(i)  check_exp(getBMode(GET_OPCODE(i)) == OpArgK, \
<span class="lineNum">     494 </span>            :         ISK(GETARG_B(i)) ? k+INDEXK(GETARG_B(i)) : base+GETARG_B(i))
<span class="lineNum">     495 </span>            : #define RKC(i)  check_exp(getCMode(GET_OPCODE(i)) == OpArgK, \
<span class="lineNum">     496 </span>            :         ISK(GETARG_C(i)) ? k+INDEXK(GETARG_C(i)) : base+GETARG_C(i))
<span class="lineNum">     497 </span>            : #define KBx(i)  \
<span class="lineNum">     498 </span>            :   (k + (GETARG_Bx(i) != 0 ? GETARG_Bx(i) - 1 : GETARG_Ax(*ci-&gt;u.l.savedpc++)))
<span class="lineNum">     499 </span>            : 
<span class="lineNum">     500 </span>            : 
<span class="lineNum">     501 </span>            : /* execute a jump instruction */
<span class="lineNum">     502 </span>            : #define dojump(ci,i,e) \
<span class="lineNum">     503 </span>            :   { int a = GETARG_A(i); \
<span class="lineNum">     504 </span>            :     if (a &gt; 0) luaF_close(L, ci-&gt;u.l.base + a - 1); \
<span class="lineNum">     505 </span>            :     ci-&gt;u.l.savedpc += GETARG_sBx(i) + e; }
<span class="lineNum">     506 </span>            : 
<span class="lineNum">     507 </span>            : /* for test instructions, execute the jump instruction that follows it */
<span class="lineNum">     508 </span>            : #define donextjump(ci)  { i = *ci-&gt;u.l.savedpc; dojump(ci, i, 1); }
<span class="lineNum">     509 </span>            : 
<span class="lineNum">     510 </span>            : 
<span class="lineNum">     511 </span>            : #define Protect(x)      { {x;}; base = ci-&gt;u.l.base; }
<span class="lineNum">     512 </span>            : 
<span class="lineNum">     513 </span>            : #define checkGC(L,c)  \
<span class="lineNum">     514 </span>            :   Protect( luaC_condGC(L,{L-&gt;top = (c);  /* limit of live values */ \
<span class="lineNum">     515 </span>            :                           luaC_step(L); \
<span class="lineNum">     516 </span>            :                           L-&gt;top = ci-&gt;top;})  /* restore top */ \
<span class="lineNum">     517 </span>            :            luai_threadyield(L); )
<span class="lineNum">     518 </span>            : 
<span class="lineNum">     519 </span>            : 
<span class="lineNum">     520 </span>            : #define arith_op(op,tm) { \
<span class="lineNum">     521 </span>            :         TValue *rb = RKB(i); \
<span class="lineNum">     522 </span>            :         TValue *rc = RKC(i); \
<span class="lineNum">     523 </span>            :         if (ttisnumber(rb) &amp;&amp; ttisnumber(rc)) { \
<span class="lineNum">     524 </span>            :           lua_Number nb = nvalue(rb), nc = nvalue(rc); \
<span class="lineNum">     525 </span>            :           setnvalue(ra, op(L, nb, nc)); \
<span class="lineNum">     526 </span>            :         } \
<span class="lineNum">     527 </span>            :         else { Protect(luaV_arith(L, ra, rb, rc, tm)); } }
<span class="lineNum">     528 </span>            : 
<span class="lineNum">     529 </span>            : 
<span class="lineNum">     530 </span>            : #define vmdispatch(o)   switch(o)
<span class="lineNum">     531 </span>            : #define vmcase(l,b)     case l: {b}  break;
<span class="lineNum">     532 </span>            : #define vmcasenb(l,b)   case l: {b}             /* nb = no break */
<span class="lineNum">     533 </span>            : 
<span class="lineNum">     534 </span><span class="lineCov">      12980 : void luaV_execute (lua_State *L) {</span>
<span class="lineNum">     535 </span><span class="lineCov">      12980 :   CallInfo *ci = L-&gt;ci;</span>
<span class="lineNum">     536 </span>            :   LClosure *cl;
<span class="lineNum">     537 </span>            :   TValue *k;
<span class="lineNum">     538 </span>            :   StkId base;
<span class="lineNum">     539 </span><span class="lineCov">      44139 :  newframe:  /* reentry point when frame changes (call/return) */</span>
<span class="lineNum">     540 </span>            :   lua_assert(ci == L-&gt;ci);
<span class="lineNum">     541 </span><span class="lineCov">      44139 :   cl = clLvalue(ci-&gt;func);</span>
<span class="lineNum">     542 </span><span class="lineCov">      44139 :   k = cl-&gt;p-&gt;k;</span>
<span class="lineNum">     543 </span><span class="lineCov">      44139 :   base = ci-&gt;u.l.base;</span>
<span class="lineNum">     544 </span>            :   /* main loop of interpreter */
<span class="lineNum">     545 </span><span class="lineCov">     612892 :   for (;;) {</span>
<span class="lineNum">     546 </span><span class="lineCov">     657031 :     Instruction i = *(ci-&gt;u.l.savedpc++);</span>
<span class="lineNum">     547 </span>            :     StkId ra;
<span class="lineNum">     548 </span><span class="lineCov">     657031 :     if ((L-&gt;hookmask &amp; (LUA_MASKLINE | LUA_MASKCOUNT)) &amp;&amp;</span>
<span class="lineNum">     549 </span><span class="lineCov">       1279 :         (--L-&gt;hookcount == 0 || L-&gt;hookmask &amp; LUA_MASKLINE)) {</span>
<span class="lineNum">     550 </span><span class="lineCov">         30 :       Protect(traceexec(L));</span>
<span class="lineNum">     551 </span>            :     }
<span class="lineNum">     552 </span>            :     /* WARNING: several calls may realloc the stack and invalidate `ra' */
<span class="lineNum">     553 </span><span class="lineCov">     657031 :     ra = RA(i);</span>
<span class="lineNum">     554 </span>            :     lua_assert(base == ci-&gt;u.l.base);
<span class="lineNum">     555 </span>            :     lua_assert(base &lt;= L-&gt;top &amp;&amp; L-&gt;top &lt; L-&gt;stack + L-&gt;stacksize);
<span class="lineNum">     556 </span><span class="lineCov">     657031 :     vmdispatch (GET_OPCODE(i)) {</span>
<span class="lineNum">     557 </span><span class="lineCov">      88182 :       vmcase(OP_MOVE,</span>
<span class="lineNum">     558 </span>            :         setobjs2s(L, ra, RB(i));
<span class="lineNum">     559 </span>            :       )
<span class="lineNum">     560 </span><span class="lineCov">      32136 :       vmcase(OP_LOADK,</span>
<span class="lineNum">     561 </span>            :         TValue *rb = k + GETARG_Bx(i);
<span class="lineNum">     562 </span>            :         setobj2s(L, ra, rb);
<span class="lineNum">     563 </span>            :       )
<span class="lineNum">     564 </span><span class="lineNoCov">          0 :       vmcase(OP_LOADKX,</span>
<span class="lineNum">     565 </span>            :         TValue *rb;
<span class="lineNum">     566 </span>            :         lua_assert(GET_OPCODE(*ci-&gt;u.l.savedpc) == OP_EXTRAARG);
<span class="lineNum">     567 </span>            :         rb = k + GETARG_Ax(*ci-&gt;u.l.savedpc++);
<span class="lineNum">     568 </span>            :         setobj2s(L, ra, rb);
<span class="lineNum">     569 </span>            :       )
<span class="lineNum">     570 </span><span class="lineCov">       7527 :       vmcase(OP_LOADBOOL,</span>
<span class="lineNum">     571 </span>            :         setbvalue(ra, GETARG_B(i));
<span class="lineNum">     572 </span>            :         if (GETARG_C(i)) ci-&gt;u.l.savedpc++;  /* skip next instruction (if C) */
<span class="lineNum">     573 </span>            :       )
<span class="lineNum">     574 </span><span class="lineCov">        724 :       vmcase(OP_LOADNIL,</span>
<span class="lineNum">     575 </span>            :         int b = GETARG_B(i);
<span class="lineNum">     576 </span>            :         do {
<span class="lineNum">     577 </span>            :           setnilvalue(ra++);
<span class="lineNum">     578 </span>            :         } while (b--);
<span class="lineNum">     579 </span>            :       )
<span class="lineNum">     580 </span><span class="lineCov">      31497 :       vmcase(OP_GETUPVAL,</span>
<span class="lineNum">     581 </span>            :         int b = GETARG_B(i);
<span class="lineNum">     582 </span>            :         setobj2s(L, ra, cl-&gt;upvals[b]-&gt;v);
<span class="lineNum">     583 </span>            :       )
<span class="lineNum">     584 </span><span class="lineCov">      48156 :       vmcase(OP_GETTABUP,</span>
<span class="lineNum">     585 </span>            :         int b = GETARG_B(i);
<span class="lineNum">     586 </span>            :         Protect(luaV_gettable(L, cl-&gt;upvals[b]-&gt;v, RKC(i), ra));
<span class="lineNum">     587 </span>            :       )
<span class="lineNum">     588 </span><span class="lineCov">      72724 :       vmcase(OP_GETTABLE,</span>
<span class="lineNum">     589 </span>            :         Protect(luaV_gettable(L, RB(i), RKC(i), ra));
<span class="lineNum">     590 </span>            :       )
<span class="lineNum">     591 </span><span class="lineCov">        931 :       vmcase(OP_SETTABUP,</span>
<span class="lineNum">     592 </span>            :         int a = GETARG_A(i);
<span class="lineNum">     593 </span>            :         Protect(luaV_settable(L, cl-&gt;upvals[a]-&gt;v, RKB(i), RKC(i)));
<span class="lineNum">     594 </span>            :       )
<span class="lineNum">     595 </span><span class="lineCov">       2613 :       vmcase(OP_SETUPVAL,</span>
<span class="lineNum">     596 </span>            :         UpVal *uv = cl-&gt;upvals[GETARG_B(i)];
<span class="lineNum">     597 </span>            :         setobj(L, uv-&gt;v, ra);
<span class="lineNum">     598 </span>            :         luaC_barrier(L, uv, ra);
<span class="lineNum">     599 </span>            :       )
<span class="lineNum">     600 </span><span class="lineCov">      82684 :       vmcase(OP_SETTABLE,</span>
<span class="lineNum">     601 </span>            :         Protect(luaV_settable(L, ra, RKB(i), RKC(i)));
<span class="lineNum">     602 </span>            :       )
<span class="lineNum">     603 </span><span class="lineCov">       6589 :       vmcase(OP_NEWTABLE,</span>
<span class="lineNum">     604 </span>            :         int b = GETARG_B(i);
<span class="lineNum">     605 </span>            :         int c = GETARG_C(i);
<span class="lineNum">     606 </span>            :         Table *t = luaH_new(L);
<span class="lineNum">     607 </span>            :         sethvalue(L, ra, t);
<span class="lineNum">     608 </span>            :         if (b != 0 || c != 0)
<span class="lineNum">     609 </span>            :           luaH_resize(L, t, luaO_fb2int(b), luaO_fb2int(c));
<span class="lineNum">     610 </span>            :         checkGC(L, ra + 1);
<span class="lineNum">     611 </span>            :       )
<span class="lineNum">     612 </span><span class="lineCov">       7190 :       vmcase(OP_SELF,</span>
<span class="lineNum">     613 </span>            :         StkId rb = RB(i);
<span class="lineNum">     614 </span>            :         setobjs2s(L, ra+1, rb);
<span class="lineNum">     615 </span>            :         Protect(luaV_gettable(L, rb, RKC(i), ra));
<span class="lineNum">     616 </span>            :       )
<span class="lineNum">     617 </span><span class="lineCov">      14340 :       vmcase(OP_ADD,</span>
<span class="lineNum">     618 </span>            :         arith_op(luai_numadd, TM_ADD);
<span class="lineNum">     619 </span>            :       )
<span class="lineNum">     620 </span><span class="lineCov">      11059 :       vmcase(OP_SUB,</span>
<span class="lineNum">     621 </span>            :         arith_op(luai_numsub, TM_SUB);
<span class="lineNum">     622 </span>            :       )
<span class="lineNum">     623 </span><span class="lineCov">       1169 :       vmcase(OP_MUL,</span>
<span class="lineNum">     624 </span>            :         arith_op(luai_nummul, TM_MUL);
<span class="lineNum">     625 </span>            :       )
<span class="lineNum">     626 </span><span class="lineCov">         37 :       vmcase(OP_DIV,</span>
<span class="lineNum">     627 </span>            :         arith_op(luai_numdiv, TM_DIV);
<span class="lineNum">     628 </span>            :       )
<span class="lineNum">     629 </span><span class="lineCov">         16 :       vmcase(OP_MOD,</span>
<span class="lineNum">     630 </span>            :         arith_op(luai_nummod, TM_MOD);
<span class="lineNum">     631 </span>            :       )
<span class="lineNum">     632 </span><span class="lineCov">         20 :       vmcase(OP_POW,</span>
<span class="lineNum">     633 </span>            :         arith_op(luai_numpow, TM_POW);
<span class="lineNum">     634 </span>            :       )
<span class="lineNum">     635 </span><span class="lineCov">         13 :       vmcase(OP_UNM,</span>
<span class="lineNum">     636 </span>            :         TValue *rb = RB(i);
<span class="lineNum">     637 </span>            :         if (ttisnumber(rb)) {
<span class="lineNum">     638 </span>            :           lua_Number nb = nvalue(rb);
<span class="lineNum">     639 </span>            :           setnvalue(ra, luai_numunm(L, nb));
<span class="lineNum">     640 </span>            :         }
<span class="lineNum">     641 </span>            :         else {
<span class="lineNum">     642 </span>            :           Protect(luaV_arith(L, ra, rb, rb, TM_UNM));
<span class="lineNum">     643 </span>            :         }
<span class="lineNum">     644 </span>            :       )
<span class="lineNum">     645 </span><span class="lineCov">          7 :       vmcase(OP_NOT,</span>
<span class="lineNum">     646 </span>            :         TValue *rb = RB(i);
<span class="lineNum">     647 </span>            :         int res = l_isfalse(rb);  /* next assignment may change this value */
<span class="lineNum">     648 </span>            :         setbvalue(ra, res);
<span class="lineNum">     649 </span>            :       )
<span class="lineNum">     650 </span><span class="lineCov">        638 :       vmcase(OP_LEN,</span>
<span class="lineNum">     651 </span>            :         Protect(luaV_objlen(L, ra, RB(i)));
<span class="lineNum">     652 </span>            :       )
<span class="lineNum">     653 </span><span class="lineCov">       7921 :       vmcase(OP_CONCAT,</span>
<span class="lineNum">     654 </span>            :         int b = GETARG_B(i);
<span class="lineNum">     655 </span>            :         int c = GETARG_C(i);
<span class="lineNum">     656 </span>            :         StkId rb;
<span class="lineNum">     657 </span>            :         L-&gt;top = base + c + 1;  /* mark the end of concat operands */
<span class="lineNum">     658 </span>            :         Protect(luaV_concat(L, c - b + 1));
<span class="lineNum">     659 </span>            :         ra = RA(i);  /* 'luav_concat' may invoke TMs and move the stack */
<span class="lineNum">     660 </span>            :         rb = b + base;
<span class="lineNum">     661 </span>            :         setobjs2s(L, ra, rb);
<span class="lineNum">     662 </span>            :         checkGC(L, (ra &gt;= rb ? ra + 1 : rb));
<span class="lineNum">     663 </span>            :         L-&gt;top = ci-&gt;top;  /* restore top */
<span class="lineNum">     664 </span>            :       )
<span class="lineNum">     665 </span><span class="lineCov">      18290 :       vmcase(OP_JMP,</span>
<span class="lineNum">     666 </span>            :         dojump(ci, i, 0);
<span class="lineNum">     667 </span>            :       )
<span class="lineNum">     668 </span><span class="lineCov">      25256 :       vmcase(OP_EQ,</span>
<span class="lineNum">     669 </span>            :         TValue *rb = RKB(i);
<span class="lineNum">     670 </span>            :         TValue *rc = RKC(i);
<span class="lineNum">     671 </span>            :         Protect(
<span class="lineNum">     672 </span>            :           if (cast_int(equalobj(L, rb, rc)) != GETARG_A(i))
<span class="lineNum">     673 </span>            :             ci-&gt;u.l.savedpc++;
<span class="lineNum">     674 </span>            :           else
<span class="lineNum">     675 </span>            :             donextjump(ci);
<span class="lineNum">     676 </span>            :         )
<span class="lineNum">     677 </span>            :       )
<span class="lineNum">     678 </span><span class="lineCov">        114 :       vmcase(OP_LT,</span>
<span class="lineNum">     679 </span>            :         Protect(
<span class="lineNum">     680 </span>            :           if (luaV_lessthan(L, RKB(i), RKC(i)) != GETARG_A(i))
<span class="lineNum">     681 </span>            :             ci-&gt;u.l.savedpc++;
<span class="lineNum">     682 </span>            :           else
<span class="lineNum">     683 </span>            :             donextjump(ci);
<span class="lineNum">     684 </span>            :         )
<span class="lineNum">     685 </span>            :       )
<span class="lineNum">     686 </span><span class="lineCov">      11039 :       vmcase(OP_LE,</span>
<span class="lineNum">     687 </span>            :         Protect(
<span class="lineNum">     688 </span>            :           if (luaV_lessequal(L, RKB(i), RKC(i)) != GETARG_A(i))
<span class="lineNum">     689 </span>            :             ci-&gt;u.l.savedpc++;
<span class="lineNum">     690 </span>            :           else
<span class="lineNum">     691 </span>            :             donextjump(ci);
<span class="lineNum">     692 </span>            :         )
<span class="lineNum">     693 </span>            :       )
<span class="lineNum">     694 </span><span class="lineCov">      17682 :       vmcase(OP_TEST,</span>
<span class="lineNum">     695 </span>            :         if (GETARG_C(i) ? l_isfalse(ra) : !l_isfalse(ra))
<span class="lineNum">     696 </span>            :             ci-&gt;u.l.savedpc++;
<span class="lineNum">     697 </span>            :           else
<span class="lineNum">     698 </span>            :           donextjump(ci);
<span class="lineNum">     699 </span>            :       )
<span class="lineNum">     700 </span><span class="lineCov">          4 :       vmcase(OP_TESTSET,</span>
<span class="lineNum">     701 </span>            :         TValue *rb = RB(i);
<span class="lineNum">     702 </span>            :         if (GETARG_C(i) ? l_isfalse(rb) : !l_isfalse(rb))
<span class="lineNum">     703 </span>            :           ci-&gt;u.l.savedpc++;
<span class="lineNum">     704 </span>            :         else {
<span class="lineNum">     705 </span>            :           setobjs2s(L, ra, rb);
<span class="lineNum">     706 </span>            :           donextjump(ci);
<span class="lineNum">     707 </span>            :         }
<span class="lineNum">     708 </span>            :       )
<span class="lineNum">     709 </span><span class="lineCov">      69994 :       vmcase(OP_CALL,</span>
<span class="lineNum">     710 </span>            :         int b = GETARG_B(i);
<span class="lineNum">     711 </span>            :         int nresults = GETARG_C(i) - 1;
<span class="lineNum">     712 </span>            :         if (b != 0) L-&gt;top = ra+b;  /* else previous instruction set top */
<span class="lineNum">     713 </span>            :         if (luaD_precall(L, ra, nresults)) {  /* C function? */
<span class="lineNum">     714 </span>            :           if (nresults &gt;= 0) L-&gt;top = ci-&gt;top;  /* adjust results */
<span class="lineNum">     715 </span>            :           base = ci-&gt;u.l.base;
<span class="lineNum">     716 </span>            :         }
<span class="lineNum">     717 </span>            :         else {  /* Lua function */
<span class="lineNum">     718 </span>            :           ci = L-&gt;ci;
<span class="lineNum">     719 </span>            :           ci-&gt;callstatus |= CIST_REENTRY;
<span class="lineNum">     720 </span>            :           goto newframe;  /* restart luaV_execute over new Lua function */
<span class="lineNum">     721 </span>            :         }
<span class="lineNum">     722 </span>            :       )
<span class="lineNum">     723 </span><span class="lineCov">       6775 :       vmcase(OP_TAILCALL,</span>
<span class="lineNum">     724 </span>            :         int b = GETARG_B(i);
<span class="lineNum">     725 </span>            :         if (b != 0) L-&gt;top = ra+b;  /* else previous instruction set top */
<span class="lineNum">     726 </span>            :         lua_assert(GETARG_C(i) - 1 == LUA_MULTRET);
<span class="lineNum">     727 </span>            :         if (luaD_precall(L, ra, LUA_MULTRET))  /* C function? */
<span class="lineNum">     728 </span>            :           base = ci-&gt;u.l.base;
<span class="lineNum">     729 </span>            :         else {
<span class="lineNum">     730 </span>            :           /* tail call: put called frame (n) in place of caller one (o) */
<span class="lineNum">     731 </span>            :           CallInfo *nci = L-&gt;ci;  /* called frame */
<span class="lineNum">     732 </span>            :           CallInfo *oci = nci-&gt;previous;  /* caller frame */
<span class="lineNum">     733 </span>            :           StkId nfunc = nci-&gt;func;  /* called function */
<span class="lineNum">     734 </span>            :           StkId ofunc = oci-&gt;func;  /* caller function */
<span class="lineNum">     735 </span>            :           /* last stack slot filled by 'precall' */
<span class="lineNum">     736 </span>            :           StkId lim = nci-&gt;u.l.base + getproto(nfunc)-&gt;numparams;
<span class="lineNum">     737 </span>            :           int aux;
<span class="lineNum">     738 </span>            :           /* close all upvalues from previous call */
<span class="lineNum">     739 </span>            :           if (cl-&gt;p-&gt;sizep &gt; 0) luaF_close(L, oci-&gt;u.l.base);
<span class="lineNum">     740 </span>            :           /* move new frame into old one */
<span class="lineNum">     741 </span>            :           for (aux = 0; nfunc + aux &lt; lim; aux++)
<span class="lineNum">     742 </span>            :             setobjs2s(L, ofunc + aux, nfunc + aux);
<span class="lineNum">     743 </span>            :           oci-&gt;u.l.base = ofunc + (nci-&gt;u.l.base - nfunc);  /* correct base */
<span class="lineNum">     744 </span>            :           oci-&gt;top = L-&gt;top = ofunc + (L-&gt;top - nfunc);  /* correct top */
<span class="lineNum">     745 </span>            :           oci-&gt;u.l.savedpc = nci-&gt;u.l.savedpc;
<span class="lineNum">     746 </span>            :           oci-&gt;callstatus |= CIST_TAIL;  /* function was tail called */
<span class="lineNum">     747 </span>            :           ci = L-&gt;ci = oci;  /* remove new frame */
<span class="lineNum">     748 </span>            :           lua_assert(L-&gt;top == oci-&gt;u.l.base + getproto(ofunc)-&gt;maxstacksize);
<span class="lineNum">     749 </span>            :           goto newframe;  /* restart luaV_execute over new Lua function */
<span class="lineNum">     750 </span>            :         }
<span class="lineNum">     751 </span>            :       )
<span class="lineNum">     752 </span><span class="lineCov">      21717 :       vmcasenb(OP_RETURN,</span>
<span class="lineNum">     753 </span>            :         int b = GETARG_B(i);
<span class="lineNum">     754 </span>            :         if (b != 0) L-&gt;top = ra+b-1;
<span class="lineNum">     755 </span>            :         if (cl-&gt;p-&gt;sizep &gt; 0) luaF_close(L, base);
<span class="lineNum">     756 </span>            :         b = luaD_poscall(L, ra);
<span class="lineNum">     757 </span>            :         if (!(ci-&gt;callstatus &amp; CIST_REENTRY))  /* 'ci' still the called one */
<span class="lineNum">     758 </span>            :           return;  /* external invocation: return */
<span class="lineNum">     759 </span>            :         else {  /* invocation via reentry: continue execution */
<span class="lineNum">     760 </span>            :           ci = L-&gt;ci;
<span class="lineNum">     761 </span>            :           if (b) L-&gt;top = ci-&gt;top;
<span class="lineNum">     762 </span>            :           lua_assert(isLua(ci));
<span class="lineNum">     763 </span>            :           lua_assert(GET_OPCODE(*((ci)-&gt;u.l.savedpc - 1)) == OP_CALL);
<span class="lineNum">     764 </span>            :           goto newframe;  /* restart luaV_execute over new Lua function */
<span class="lineNum">     765 </span>            :         }
<span class="lineNum">     766 </span>            :       )
<span class="lineNum">     767 </span><span class="lineCov">      16062 :       vmcase(OP_FORLOOP,</span>
<span class="lineNum">     768 </span>            :         lua_Number step = nvalue(ra+2);
<span class="lineNum">     769 </span>            :         lua_Number idx = luai_numadd(L, nvalue(ra), step); /* increment index */
<span class="lineNum">     770 </span>            :         lua_Number limit = nvalue(ra+1);
<span class="lineNum">     771 </span>            :         if (luai_numlt(L, 0, step) ? luai_numle(L, idx, limit)
<span class="lineNum">     772 </span>            :                                    : luai_numle(L, limit, idx)) {
<span class="lineNum">     773 </span>            :           ci-&gt;u.l.savedpc += GETARG_sBx(i);  /* jump back */
<span class="lineNum">     774 </span>            :           setnvalue(ra, idx);  /* update internal index... */
<span class="lineNum">     775 </span>            :           setnvalue(ra+3, idx);  /* ...and external index */
<span class="lineNum">     776 </span>            :         }
<span class="lineNum">     777 </span>            :       )
<span class="lineNum">     778 </span><span class="lineCov">       4469 :       vmcase(OP_FORPREP,</span>
<span class="lineNum">     779 </span>            :         const TValue *init = ra;
<span class="lineNum">     780 </span>            :         const TValue *plimit = ra+1;
<span class="lineNum">     781 </span>            :         const TValue *pstep = ra+2;
<span class="lineNum">     782 </span>            :         if (!tonumber(init, ra))
<span class="lineNum">     783 </span>            :           luaG_runerror(L, LUA_QL(&quot;for&quot;) &quot; initial value must be a number&quot;);
<span class="lineNum">     784 </span>            :         else if (!tonumber(plimit, ra+1))
<span class="lineNum">     785 </span>            :           luaG_runerror(L, LUA_QL(&quot;for&quot;) &quot; limit must be a number&quot;);
<span class="lineNum">     786 </span>            :         else if (!tonumber(pstep, ra+2))
<span class="lineNum">     787 </span>            :           luaG_runerror(L, LUA_QL(&quot;for&quot;) &quot; step must be a number&quot;);
<span class="lineNum">     788 </span>            :         setnvalue(ra, luai_numsub(L, nvalue(ra), nvalue(pstep)));
<span class="lineNum">     789 </span>            :         ci-&gt;u.l.savedpc += GETARG_sBx(i);
<span class="lineNum">     790 </span>            :       )
<span class="lineNum">     791 </span><span class="lineCov">      52466 :       vmcasenb(OP_TFORCALL,</span>
<span class="lineNum">     792 </span>            :         StkId cb = ra + 3;  /* call base */
<span class="lineNum">     793 </span>            :         setobjs2s(L, cb+2, ra+2);
<span class="lineNum">     794 </span>            :         setobjs2s(L, cb+1, ra+1);
<span class="lineNum">     795 </span>            :         setobjs2s(L, cb, ra);
<span class="lineNum">     796 </span>            :         L-&gt;top = cb + 3;  /* func. + 2 args (state and index) */
<span class="lineNum">     797 </span>            :         Protect(luaD_call(L, cb, GETARG_C(i), 1));
<span class="lineNum">     798 </span>            :         L-&gt;top = ci-&gt;top;
<span class="lineNum">     799 </span>            :         i = *(ci-&gt;u.l.savedpc++);  /* go to next instruction */
<span class="lineNum">     800 </span>            :         ra = RA(i);
<span class="lineNum">     801 </span>            :         lua_assert(GET_OPCODE(i) == OP_TFORLOOP);
<span class="lineNum">     802 </span>            :         goto l_tforloop;
<span class="lineNum">     803 </span>            :       )
<span class="lineNum">     804 </span><span class="lineCov">      52466 :       vmcase(OP_TFORLOOP,</span>
<span class="lineNum">     805 </span>            :         l_tforloop:
<span class="lineNum">     806 </span>            :         if (!ttisnil(ra + 1)) {  /* continue loop? */
<span class="lineNum">     807 </span>            :           setobjs2s(L, ra, ra + 1);  /* save control variable */
<span class="lineNum">     808 </span>            :            ci-&gt;u.l.savedpc += GETARG_sBx(i);  /* jump back */
<span class="lineNum">     809 </span>            :         }
<span class="lineNum">     810 </span>            :       )
<span class="lineNum">     811 </span><span class="lineCov">       1386 :       vmcase(OP_SETLIST,</span>
<span class="lineNum">     812 </span>            :         int n = GETARG_B(i);
<span class="lineNum">     813 </span>            :         int c = GETARG_C(i);
<span class="lineNum">     814 </span>            :         int last;
<span class="lineNum">     815 </span>            :         Table *h;
<span class="lineNum">     816 </span>            :         if (n == 0) n = cast_int(L-&gt;top - ra) - 1;
<span class="lineNum">     817 </span>            :         if (c == 0) {
<span class="lineNum">     818 </span>            :           lua_assert(GET_OPCODE(*ci-&gt;u.l.savedpc) == OP_EXTRAARG);
<span class="lineNum">     819 </span>            :           c = GETARG_Ax(*ci-&gt;u.l.savedpc++);
<span class="lineNum">     820 </span>            :         }
<span class="lineNum">     821 </span>            :         luai_runtimecheck(L, ttistable(ra));
<span class="lineNum">     822 </span>            :         h = hvalue(ra);
<span class="lineNum">     823 </span>            :         last = ((c-1)*LFIELDS_PER_FLUSH) + n;
<span class="lineNum">     824 </span>            :         if (last &gt; h-&gt;sizearray)  /* needs more space? */
<span class="lineNum">     825 </span>            :           luaH_resizearray(L, h, last);  /* pre-allocate it at once */
<span class="lineNum">     826 </span>            :         for (; n &gt; 0; n--) {
<span class="lineNum">     827 </span>            :           TValue *val = ra+n;
<span class="lineNum">     828 </span>            :           luaH_setint(L, h, last--, val);
<span class="lineNum">     829 </span>            :           luaC_barrierback(L, obj2gco(h), val);
<span class="lineNum">     830 </span>            :         }
<span class="lineNum">     831 </span>            :         L-&gt;top = ci-&gt;top;  /* correct top (in case of previous open call) */
<span class="lineNum">     832 </span>            :       )
<span class="lineNum">     833 </span><span class="lineCov">       2272 :       vmcase(OP_CLOSURE,</span>
<span class="lineNum">     834 </span>            :         Proto *p = cl-&gt;p-&gt;p[GETARG_Bx(i)];
<span class="lineNum">     835 </span>            :         Closure *ncl = getcached(p, cl-&gt;upvals, base);  /* cached closure */
<span class="lineNum">     836 </span>            :         if (ncl == NULL)  /* no match? */
<span class="lineNum">     837 </span>            :           pushclosure(L, p, cl-&gt;upvals, base, ra);  /* create a new one */
<span class="lineNum">     838 </span>            :         else
<span class="lineNum">     839 </span>            :           setclLvalue(L, ra, ncl);  /* push cashed closure */
<span class="lineNum">     840 </span>            :         checkGC(L, ra + 1);
<span class="lineNum">     841 </span>            :       )
<span class="lineNum">     842 </span><span class="lineCov">         57 :       vmcase(OP_VARARG,</span>
<span class="lineNum">     843 </span>            :         int b = GETARG_B(i) - 1;
<span class="lineNum">     844 </span>            :         int j;
<span class="lineNum">     845 </span>            :         int n = cast_int(base - ci-&gt;func) - cl-&gt;p-&gt;numparams - 1;
<span class="lineNum">     846 </span>            :         if (b &lt; 0) {  /* B == 0? */
<span class="lineNum">     847 </span>            :           b = n;  /* get all var. arguments */
<span class="lineNum">     848 </span>            :           Protect(luaD_checkstack(L, n));
<span class="lineNum">     849 </span>            :           ra = RA(i);  /* previous call may change the stack */
<span class="lineNum">     850 </span>            :           L-&gt;top = ra + n;
<span class="lineNum">     851 </span>            :         }
<span class="lineNum">     852 </span>            :         for (j = 0; j &lt; b; j++) {
<span class="lineNum">     853 </span>            :           if (j &lt; n) {
<span class="lineNum">     854 </span>            :             setobjs2s(L, ra + j, base - n + j);
<span class="lineNum">     855 </span>            :           }
<span class="lineNum">     856 </span>            :           else {
<span class="lineNum">     857 </span>            :             setnilvalue(ra + j);
<span class="lineNum">     858 </span>            :           }
<span class="lineNum">     859 </span>            :         }
<span class="lineNum">     860 </span>            :       )
<span class="lineNum">     861 </span><span class="lineNoCov">          0 :       vmcase(OP_EXTRAARG,</span>
<span class="lineNum">     862 </span>            :         lua_assert(0);
<span class="lineNum">     863 </span>            :       )
<span class="lineNum">     864 </span>            :     }
<span class="lineNum">     865 </span><span class="lineCov">     612892 :   }</span>
<span class="lineNum">     866 </span>            : }
<span class="lineNum">     867 </span>            : 
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.13</a></td></tr>
  </table>
  <br>

</body>
</html>
